﻿@using DoAnForum.Models
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<ul class="nav nav-tabs" id="myTab">
  <li class="active"><a href="#inbox">Hộp thư đến</a></li>
  <li><a href="#sent">Thư đã gửi</a></li>
</ul>
 
<div class="tab-content">
    <div class="tab-pane active" id="inbox">
        @if (ViewBag.listInbox != null)
        {
            <table class="table table-bordered table-striped">
                <thead>
                    <tr>
                        <th>Người gửi</th>
                        <th>Tiêu đề</th>
                        <th>Ngày gửi</th>
                        <th>Chưa đọc</th>
                        <th>Xóa</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var inbox in (List<InboxModel>) ViewBag.listInbox)
                    {
                        <tr>
                            <td>
                                <strong><a href=@Url.Action("ShowProfile", "Account", new {userName = inbox.FromUserName})>@Html.Raw(inbox.FromUserName)</a></strong>
                            </td>
                            <td>
                                @Html.ActionLink(inbox.Subject, "ViewMessage", new {id = inbox.MessageId})
                            </td>
                            <td>@inbox.CreateDate.ToShortDateString()</td>
                            <td>@Html.DisplayFor(modelItem => inbox.UnRead)</td>
                            <td>
                                <a class="privatemessagedelete" rel="@inbox.MessageId">
                                    <i class="icon-remove"></i>  
                                </a>
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        }
        @if (ViewBag.listInbox == null)
        {
            <span class="span3">Hộp thư trống</span>
        }
    </div>
    <div class="tab-pane" id="sent">
        @if (ViewBag.listsentItem != null)
        {
            <table class="table table-bordered table-striped">
                <thead>
                    <tr>
                        <th>Người nhận</th>
                        <th>Tiêu đề</th>
                        <th>Ngày gửi</th>
                        <th>Xóa</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var sentItem in (List<SentItemModel>) ViewBag.listsentItem)
                    {
                        <tr>
                            <td>
                                <strong><a href=@Url.Action("ShowProfile", "Account", new {userName = sentItem.ToUserName})>@Html.Raw(sentItem.ToUserName)</a></strong>
                            </td>
                            <td>
                                @Html.ActionLink(sentItem.Subject, "ViewMessage", new {id = sentItem.MessageId})
                            </td>
                            <td>@sentItem.CreateDate.ToShortDateString()</td>
                            <td>
                                <a class="privatemessagedelete" rel="@sentItem.MessageId">
                                    <i class="icon-remove"></i>  
                                </a>
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        }
        @if (ViewBag.listsentItem == null)
        {
            <span class="span3">Hộp thư trống</span>
        }
    </div>
</div>

<div class="right btnPmessage">
    <a href=@Url.Action("CreateMessage") class="btn btn-large btn-success newTopic">Tạo thư mới</a>
</div>
 
<script>
    $(function() {
        $('#myTab a:active').tab('show');
    });
    $('#myTab a').click(function(e) {
        e.preventDefault();
        $(this).tab('show');
    });
</script>